const http = require("http");

const server = http.createServer((req, res) => {
  if (req.method === "POST") {
    console.log("content-type", req.headers["content-type"]);
    //接收数据
    let postdata = "";
    req.on("data", (chunk) => {
      postdata += chunk.toString();
    });
    req.on("end", () => {
      console.log(postdata);
      res.end("hello world"); //在这里返回，因为是异步
    });
  }
});

server.listen("8080", () => {
  console.log("running in 8080...");
});
